/**
  ******************************************************************************
  * @file    bsp_can.h
  * @author  
  * @version V1.0
  * @date    2017-xx-xx
  * @brief   
  ******************************************************************************
  * @attention
  *
  *
  ******************************************************************************
  */
	
#ifndef	__BSP_CAN_H
#define	__BSP_CAN_H

#ifdef	__cplusplus
extern	"C"	{
#endif
	
#include	"stm32f4xx.h"

#define CAN_CLK                    	RCC_APB1Periph_CAN1
#define CAN_RX_IRQ									CAN1_RX0_IRQn
#define CAN_RX_IRQHandler						CAN1_RX0_IRQHandler

#define CAN_RX_PIN                 	GPIO_Pin_8
#define CAN_TX_PIN                 	GPIO_Pin_9
#define CAN_TX_GPIO_PORT          	GPIOB
#define CAN_RX_GPIO_PORT          	GPIOB
#define CAN_TX_GPIO_CLK           	RCC_AHB1Periph_GPIOB
#define CAN_RX_GPIO_CLK           	RCC_AHB1Periph_GPIOB
#define CAN_AF_PORT                	GPIO_AF_CAN1
#define CAN_RX_SOURCE              	GPIO_PinSource8
#define CAN_TX_SOURCE              	GPIO_PinSource9 	
	
void CAN_Config(void);
	
#ifdef	__cplusplus
						}
#endif	

class	cCAN
{
	public:
		cCAN(CAN_TypeDef* CANx);
		void	SetID(uint32_t id);
		void	SendStdData(uint8_t* data, uint8_t length);
		void	SendExtData(uint8_t* data, uint8_t length);
	private:
		CanTxMsg tx_message;
		CAN_TypeDef* can_port;
		uint8_t	rx_data[8];
};
						
#endif



